 
package com.cy.tool;

import java.util.List;

public class Page<T> {
	// / <summary>
	// / 当前页码
	// / </summary>
	public int pageNo;
	// / <summary>
	// / 页条数
	// / </summary>
	public int pageSize;
	// / <summary>
	// / 总条数
	// / </summary>
	public int totalCount;
	// / <summary>
	// / 总页数
	// / </summary>
	public int totalPage;
	// / <summary>
	// / 结果
	// / </summary>
	public List<T> result;

	public Page() {
		this.pageNo = 1;
		this.pageSize = 20;
		this.totalCount = 0;
		this.totalCount = 1;
	}

	public Page(List<T> result) {
		this.pageNo = 1;
		this.pageSize = 20;
		this.totalCount = result.size();
		if(result.size() > 20)
		{
			if(result.size()%20 != 0)
			{
				this.totalPage = result.size() / 20 + 1;
			}
			else {
				this.totalPage = result.size() / 20;
			}
		}
		else {
			this.totalPage = 1;
		}
		this.result = result;
	}

	public Page(List<T> result, int pageNo) {
		this.pageNo = pageNo;
		this.pageSize = 20;
		this.totalCount = result.size();
		if(result.size() > 20)
		{
			if(result.size()%20 != 0)
			{
				this.totalPage = result.size() / 20 + 1;
			}
			else {
				this.totalPage = result.size() / 20;
			}
		}
		else {
			this.totalPage = 1;
		}
		this.result = result;
	}

	public Page(List<T> result, int pageNo, int pageSize) {
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.totalCount = result.size();
		if(result.size() > pageSize)
		{
			if(result.size()%pageSize != 0)
			{
				this.totalPage = result.size() / pageSize + 1;
			}
			else {
				this.totalPage = result.size() / pageSize;
			}
		}
		else {
			this.totalPage = 1;
		}
		this.result = result;
	}

	public Page(List<T> result, int pageNo, int pageSize, int totalCount) {
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.totalCount = totalCount;
		if(totalCount > pageSize)
		{
			if(totalCount%pageSize != 0)
			{
				this.totalPage = totalCount / pageSize + 1;
			}
			else {
				this.totalPage = totalCount / pageSize;
			}
		}
		else {
			this.totalPage = 1;
		}
		this.result = result;
	}
}
